package com.gfxy.commons.model;

public enum WeekEnum {



    SUN(1,"星期日"),MON(2,"星期一"),
    TUE(3,"星期二"),WED(4,"星期三"),
    THU(5,"星期四"),FRI(6,"星期五"),
    SAT(7,"星期六");

    private final int index;
    private final String name;

    WeekEnum(int index, String name) {
        this.index = index;
        this.name = name;
    }


    public static WeekEnum getWeekEnumByIndex(int index){
        WeekEnum result = null;
        for(WeekEnum weekEnum : WeekEnum.values()){
            if(weekEnum.getIndex() == index){
                result = weekEnum;
                break;
            }
        }
        if(result == null){
            throw new IllegalArgumentException("错误的枚举index值[" + index + "], 无法找到对应的枚举");
        } else {
            return result;
        }

    }

    public int getIndex() {
        return index;
    }

    public String getName() {
        return name;
    }
}
